﻿using Architecture.API.Application.TraceabilityCommand.ShoppingNameCommand;
using MediatR;
using Traceability.Domain;
using Traceability.Domain.Service.ShoppingNameService;

namespace Architecture.API.Application.TraceabilityCommandHandler.ShoppingNameCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShoppingNameSeachCommandHandler : IRequestHandler<ShoppingNameSeachCommand, List<ShoppingName>>
    {
        /// <summary>
        /// 商品名称服务
        /// </summary>
        protected readonly IShoppingNameService shoppingNameService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="shoppingNameService">商品名称服务</param>
        public ShoppingNameSeachCommandHandler(IShoppingNameService shoppingNameService)
        {
            this.shoppingNameService = shoppingNameService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<ShoppingName>> Handle(ShoppingNameSeachCommand request, CancellationToken cancellationToken)
        {
            return await shoppingNameService.GetShoppingNameList();
        }
    }
}
